<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = $_RQ['psize']?:15;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['cpcode'])){
		$params['cpcode like']='%'.trim($_RQ['cpcode']).'%';
		$return['params']['cpcode']=$_RQ['cpcode'];
	}
	if(!empty($_RQ['ordersn'])){
		$params['ordersn like']='%'.trim($_RQ['ordersn']).'%';
		$return['params']['ordersn']=$_RQ['ordersn'];
	}
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_fahuo_log',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$item){
		$status=pdo_getcolumn('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['orderid']),'status');
		if($status>=2){
			$item['status']=$status;
		}
	}
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'export'=>'export',
		'tabs'=>array(
			array('op'=>'list','title'=>'打印面单模板'),
		),
		'list'=>array('data'=>'list','edit'=>false,'total'=>$total,'psize'=>$psize,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'cpcode','title'=>'公司编号','type'=>'string'),
			array('type'=>'select','title'=>'快递公司','name'=>'express_id','options'=>'express','option_title'=>'name'),
			array('name'=>'expresssn','title'=>'快递单号','type'=>'string'),
			array('name'=>'templateurl','title'=>'模板地址','type'=>'string_copy'),
			//array('name'=>'templatetitle','title'=>'模板名称','type'=>'string'),
			array('name'=>'starttime','title'=>'预约上门收件时间','type'=>'string'),
			array('name'=>'endtime','title'=>'预约上门截至时间','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'cpcode','width'=>'15','title'=>'公司编号','type'=>'string'),
			array('name'=>'ordersn','width'=>'15','title'=>'订单号','type'=>'string'),
		)
	);
	$return['express']=$this->express_types;
	$return['htmls']=$htmls;
	$return['status']=array(
		'0'=>'待上门取件',
		'1'=>'已通知取件',
		'2'=>'待收货',
		'3'=>'已完成',
		'4'=>'已关闭',
		'5'=>'申请退款',
		'6'=>'已退款',
		'7'=>'异常报备',
		'10'=>'拼单中',
		'11'=>'待售后接单',
		'12'=>'售后已接单',
		'13'=>'售后上门',
		'14'=>'售后异常',
		'15'=>'待售后',
		'16'=>'售后完成',
		'21'=>'部分发货',
		'-1'=>'已关闭',
	);
	exi($return);
}
?>